package com.gl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gl.common.vo.JsonResult;
import com.gl.pojo.Product;
import com.gl.service.ProductService;

/**
 * 	前端商品控制层
 * @author FengLong
 */
@RestController
@RequestMapping("/products/")
public class ProductController {
	@Autowired(required = true)
	private ProductService productService;
	/**
	 * 	前台分页显示商品信息
	 * 	图片,名称,价格
	 */
	@RequestMapping("doFindPageProducts")
	public JsonResult doFindPageProducts(String name,Integer pageCurrent) {
		return new JsonResult(productService.findPageProducts(name, pageCurrent));
	}
	/**
	 *	后台分页显示商品信息
	 */
	@RequestMapping("doFindSysPageProducts")
	public JsonResult doFindSysPageProducts(String name,Integer pageCurrent) {
		return new JsonResult(productService.findSysPageProducts(name, pageCurrent));
	}
	/**
	 * 前台基于id查询商品详情
	 */
	@RequestMapping("doFindProductById")
	public JsonResult doFindProductById(Integer id) {
		return new JsonResult(productService.findProductById(id));
	}
	/**
	 * 	后台修改
	 */
	@RequestMapping("doUpdateProduct")
	public JsonResult doUpdateProduct(Product entity) {
		return new JsonResult(productService.updateProduct(entity));
	}
	/**
	 *	后台删除 
	 */
	@RequestMapping("doDeleteProduct")
	public JsonResult doDeleteProduct(Integer[] ids) {
		return new JsonResult(productService.deleteProduct(ids));
	}
	/**
	 *	后台新增 
	 */
	@RequestMapping("doSaveProduct")
	public JsonResult doSaveProduct(Product entity) {
		return new JsonResult(productService.saveProduct(entity));
	}
	
}
